package com.wenli.lt.controller;


import com.wenli.lt.entity.po.ImgPo;
import com.wenli.lt.service.IImgService;
import com.wenli.lt.util.CommonResponse;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lt
 * @since 2021-03-23
 */
@RestController
@RequestMapping("img")
@Api(tags = "商品图片保存")
public class ImgController {

    @Autowired
    IImgService iImgService;
    @PostMapping("/saveGoodsImg")
    @ApiOperation("保存发布图片")

    public CommonResponse saveGoodsImg( @RequestBody  @ApiParam(name = "imgs", value = "商品id 图片路径") ImgPo imgPo){
        Boolean aBoolean = iImgService.saveGoodsImg(imgPo.getGoodsId(),imgPo.getImgs());
        if(aBoolean){
            return new CommonResponse("新增成功!");
        }else {
            return new CommonResponse(CommonResponse.ERROR_CODE,"数据出错,请联系管理员");
        }

    }

}
